from aip import AipSpeech

APP_ID = "11724097"
API_KEY = "7vVTSUnR1CGiTEChn4DwX5q0"
SECRET_KEY= "I1PEkvH12zL42Q0wN9NgiwGlULhZZEOn"

client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)


# 识别正确返回语音二进制 错误则返回dict 参照下面错误码
def gen_audio(text):
    result  = client.synthesis(text, 'zh', 1, {
        'vol': 5,
    })
    if not isinstance(result, dict):
        with open('auido.mp3', 'wb') as f:
            f.write(result)
